Docker安装jenkins

查照jenkins 版本

1
2
3
4
5
 docker search jenkins
```
#### 拉取jenkins
```
docker pull jenkins:2.60.3

创建jenkins 的挂载目录

1
mkdir /mydata/jenkins

给jenkins挂载目录赋权

1
2
3
 chown -R 1000:1000 /mydata/jenkins
```
>注意:此步必须赋权限不然启动报错

touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

1
#### jenkins启动

docker run –name jenkins -p 9997:8080 -v /mydata/jenkins:/var/jenkins_home -d jenkins:2.60.3

1
2
3
4
 
#### 访问jenkin页面之后

#### 然后停止jenkins

dockers stop jenkins

1
#### 修改默认的插件下载地址 进入“{你的Jenkins工作目录}/updates/”目录下修改“default.json”

sed -i ‘s#http://updates.jenkins-ci.org/download#https://mirrors.tuna.tsinghua.edu.cn/jenkins#g' default.json && sed -i ‘s#http://www.google.com#https://www.baidu.com#g' default.json

1
####  然后启动jenkins

dockers start jenkins

1
#### 远程登录之后需要输入用户密码在

/var/jenkins_home/secrets/initialAdminPassword

1
#### 挂载之后在

/mydata/jenkins/secrets/initialAdminPassword

```

插件可以先不安装,之后进行安装

继开 wechat
欢迎加我的微信,共同交流技术